package com.open.capacity.talented.util;


import com.open.capacity.talented.model.Menu;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class MenuUtil {
    public static List<Menu> buildMenuTree(List<Menu> menuList, Long pid) {
        List<Menu> treeList = new ArrayList<>();
        menuList.forEach(menu -> {
            if (StringUtils.equals(pid.toString(), menu.getParentId().toString())) {
                menu.setChildMenus(buildMenuTree(menuList, menu.getId()));
                treeList.add(menu);
            }
        });
        return treeList;
    }
}
